<template>
    <view>


      <view v-if="show_subs==true && store_subs.length>0" class="drawer_screen">
        <view class="drawer_box p-8">
          <view class="w-full py-4 text-xl text-center border-0 border-b border-solid border-gray-100">
            本店铺的关联店铺
          </view>
          <view @click="gotoStore(item.id)" class="my-2 flex justify-between items-center" v-for="item in store_subs" :key="item.id">
            <image class="w-12 h-12 mx-4" :src="item.logo"></image>
            <view class="flex-1">
              <view>
                {{ item.name }}
              </view>
              <view>
                {{ item.address }}
              </view>
            </view>
          </view>
          <view>
            <button class="w-full bg-blue-500 btn-green" @click="close_store_subs_drawer">关闭</button>
          </view>
        </view>
      </view>

        <view class="loadinggif" v-if="isloading">
            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/loading.gif"></image>
        </view>
        <block v-if="!isloading">

            <daya-clone-navbar :prop_clone_navbar="clone_navbar" :prop_is_ipx="is_ipx"/>

            <view class="sjinfohd1" v-if="storeset.top_style == '2'">
                <view class="sjinfohd1dbdt flex-row flex-y-center">
                    <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/location.png"></image>
                    <view class="flex-grow-1">{{ weizhi }}</view>
                    <view class="flex-grow-0">{{ store.name }}</view>
                </view>
                <swiper
                    autoplay="auto"
                    :circular="true"
                    duration="500"
                    indicatorActiveColor="#34AAFF"
                    indicatorColor="white"
                    :indicatorDots="true"
                    interval="5000"
                    style="width: 100%; height: 100%"
                >
                    <swiper-item :data-index="index" v-for="(item, index) in slider" :key="item.unique">
                        <image
                            @tap="jumps"
                            class="img"
                            :data-appid="item.appid"
                            :data-id="item.id"
                            :data-name="item.title"
                            :data-src="item.src"
                            :data-type="item.item"
                            :data-wb_src="item.src2"
                            mode="aspectFill"
                            :src="item.logo"
                        ></image>
                    </swiper-item>
                </swiper>
            </view>
            <view class="sjinfohd flex-row flex-y-center" :style="'background:' + color" v-if="storeset.top_style == '1'">
                <image class="sjleftimg flex-grow-0" :src="store.logo"></image>
                <view class="sjright flex-grow-1 flex-col flex-x-center">
                    <view class="sjright1 flex-bet flex-y-center">
                        <view class="sjright1-l gobyndsingle">{{ store.name }}</view>
                    </view>
                    <view class="sjright2 flex-row flex-y-center">
                        <image class="sjright2-l" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/laba.png"></image>
                        <view class="flex-grow-1 gobyndsingle">{{ store.announcement }}</view>
                    </view>
                    <view @tap="lookck" class="sjright3 flex-bet flex-y-center">
                        <view class="flex-row flex-y-center">
                            <view class="sjright3text" style="padding-left: 0">￥{{ store.start_at }}起送</view>
                            <view class="sjright3text">{{ storeset.ps_time }}送达</view>
                            <view class="sjright3text" style="border-right: 0">{{ storeset.ps_mode }}（{{ storeset.ps_jl }}公里内）</view>
                        </view>
                        <view class="flex-row flex-y-center">
                            <image class="sjright3-r" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/jiantou.png"></image>
                        </view>
                    </view>
                </view>
            </view>
            <view class="sjinfonav">
                <scroll-view class="nav-two" :scrollX="true">
                    <view
                        @tap="selectednavbar"
                        :class="'toatal_head  ' + (selectedindex == index ? 'selsect' : 'default')"
                        :data-index="index"
                        :style="'color:' + (selectedindex == index ? color : '')"
                        v-for="(item, index) in navbar"
                        :key="index"
                    >
                        {{ item }}

                        <view class="toatal_text" :style="'background-color: ' + color" v-if="selectedindex == index"></view>
                    </view>
                </scroll-view>
            </view>
            <view class="swiper-wrap">
                <swiper @change="swiperChange" class="swiper" :current="selectedindex" duration="500" :style="'height:' + (storeset.top_style == '1' ? '69vh' : '93vh') + ';'">
                    <swiper-item class="swiper-item1">
                        <view @tap="lookck" class="lbhd flex-row flex-y-center">
                            <view class="flex-grow-1">
                                <swiper :autoplay="true" :circular="true" class="lbhd-swiper" interval="2000" :vertical="true">
                                    <swiper-item v-if="storeset.xyh_open == '1'">
                                        <view class="lbhd-view flex-row flex-y-center">
                                            <view class="xyh">新</view>
                                            <view class="gobyndsingle">新用户下单立减{{ storeset.xyh_money }}元(不与其它活动同享)</view>
                                        </view>
                                    </swiper-item>
                                    <swiper-item v-if="reduction.length != 0">
                                        <view class="flex-row flex-y-center">
                                            <view class="mj">减</view>
                                            <view class="gobyndsingle">
                                                <text v-for="(item, index) in reduction" :key="index">满{{ item.full }}减{{ item.reduction }},</text>
                                            </view>
                                        </view>
                                    </swiper-item>
                                </swiper>
                            </view>
                            <image class="flex-grow-0 down" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/down.png"></image>
                        </view>
                        <view class="dclb flex-row">
                            <scroll-view class="leftsv flex-col" :scrollIntoView="toType" :scrollY="true" :style="'height:' + (storeset.top_style == '1' ? '56vh' : '71vh') + ';'">
                                <view
                                    @tap="selectMenu"
                                    :class="'menu-item border-1px ' + (index == catalogSelect ? 'active' : 'selsect')"
                                    :data-id="item.id"
                                    :data-item-index="index"
                                    :id="'type' + index"
                                    v-if="item.goods && item.goods.length != 0"
                                    v-for="(item, index) in dishes"
                                    :key="item.value"
                                >
                                    <view class="goods_border" :style="'background:' + color" v-if="index == catalogSelect"></view>

                                    <view class="text">
                                        {{ item.type_name }}
                                    </view>
                                </view>
                            </scroll-view>
                            <scroll-view
                                @scroll="scrollFun"
                                @scrolltoupper="tozd"
                                class="rightsv flex-grow-1 flex-col"
                                lowerThreshold="0"
                                :scrollIntoView="toView"
                                :scrollY="true"
                                :style="'height:' + (storeset.top_style == '1' ? '56vh' : '71vh') + ';'"
                            >
                                <view :id="'order' + parentIndex" v-if="disheitem.good.length > 0" v-for="(disheitem, parentIndex) in dishes" :key="parentIndex">
                                    <view class="youhui">
                                        <view class="yh">
                                            {{ disheitem.type_name }}
                                            <text>({{ disheitem.good.length }})</text>
                                        </view>
                                    </view>

                                    <view class="cplb flex-row" :data-id="disheitem.id" v-for="(gooditem, goodindex) in disheitem.good" :key="goodindex">
                                        <image
                                            @tap="spxqck"
                                            class="cpleftimg flex-grow-0"
                                            :data-goodid="gooditem.id"
                                            :data-item-index="goodindex"
                                            :data-parentIndex="parentIndex"
                                            :src="gooditem.logo"
                                        ></image>

                                        <view class="cplbright flex-grow-1 flex-col">
                                            <view class="cplbright1 flex-bet">
                                                <view class="cplbright1-l">{{ gooditem.name }}</view>
                                                <view class="cplbright1-r" v-if="gooditem.is_zp == '1'">招牌</view>
                                            </view>
                                            <view class="cplbright2 flex-bet flex-y-center">
                                                <view class="gobyndsingle">{{ gooditem.content }}</view>
                                            </view>
                                            <view class="cplbright3 flex-row flex-y-center">
                                                <view class="cplbright31">月销{{ gooditem.sales }}笔</view>
                                                <view class="cplbright32" v-if="gooditem.restrict_num != '0'">限购{{ gooditem.restrict_num }}份</view>
                                                <view class="cplbright33" v-if="gooditem.start_num != '0'">{{ gooditem.start_num }}份起售</view>
                                            </view>
                                            <view
                                                class="cplbright3 flex-row flex-y-center"
                                                style="margin-top: 10rpx"
                                                v-if="xtxx.hygn == '1' && gooditem.vip_money != '0.00' && gooditem.is_gg != '2'"
                                            >
                                                <view class="vipzk flex-row flex-y-center">
                                                    <image mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/personal/huangg.png"></image>
                                                    <view>专享</view>
                                                </view>
                                                <view class="vipzx">会员价：￥{{ gooditem.vip_money }}</view>
                                            </view>
                                            <view class="cplbright4 flex-bet">
                                                <view class="cplbright4-l flex-grow-1">
                                                    <text>￥{{ gooditem.money }}</text>
                                                    <text v-if="gooditem.money2 != 0">￥{{ gooditem.money2 }}</text>
                                                </view>
                                                <view class="cartControl flex-grow-0">
                                                    <view @tap.stop.prevent="ggcartdec" class="cartdec" v-if="gooditem.is_gg == '2' && gooditem.quantity > 0"></view>
                                                    <view
                                                        @tap.stop.prevent="cartdec"
                                                        class="cartdec"
                                                        :data-goodid="gooditem.id"
                                                        :data-item-index="goodindex"
                                                        :data-parentIndex="parentIndex"
                                                        v-if="gooditem.is_gg != '2' && gooditem.quantity > 0"
                                                    ></view>
                                                    <view class="goodsnum" v-if="gooditem.quantity > 0">{{ gooditem.quantity }}</view>
                                                    <form @reset="formReset" @submit="cartaddformSubmit" :reportSubmit="true">
                                                        <button
                                                            @tap.stop.prevent="spggck"
                                                            class="xgg"
                                                            :data-goodid="gooditem.id"
                                                            :data-item-index="goodindex"
                                                            :data-parentIndex="parentIndex"
                                                            formType="submit"
                                                            :style="'background:' + color"
                                                            v-if="gooditem.is_gg == '2'"
                                                        >
                                                            选规格
                                                        </button>
                                                    </form>
                                                    <form @reset="formReset" @submit="cartaddformSubmit" :reportSubmit="true">
                                                        <button
                                                            @tap.stop.prevent="cartadd"
                                                            class="cartadd"
                                                            :data-goodid="gooditem.id"
                                                            :data-item-index="goodindex"
                                                            :data-parentIndex="parentIndex"
                                                            formType="submit"
                                                            :style="'background:' + color"
                                                            v-if="gooditem.is_gg != '2' && gooditem.inventory > 0"
                                                        ></button>
                                                    </form>
                                                </view>
                                                <view class="xgg" style="background: #cccccc" v-if="gooditem.is_gg != '2' && gooditem.inventory <= 0">已售完</view>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                                <view class="jzz" v-if="cpjzz">
                                    <image class="Rotation" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/jzz.png"></image>
                                    <view>加载中...</view>
                                </view>
                                <view class="jzwb" v-else>
                                    <view class="hx"></view>
                                    <view class="wz">加载完毕</view>
                                    <view class="hx"></view>
                                </view>
                            </scroll-view>
                        </view>
                    </swiper-item>
                    <swiper-item class="swiper-item2">
                        <scroll-view scrollY @scrolltolower="pjmore" style="height: 100%">
                            <view class="evaluate">
                                <view class="evaluate_head">
                                    <text>综合评分</text>
                                    <text>{{ store.sales }}分</text>
                                </view>
                                <view class="evaluate_label">
                                    <view
                                        @tap="pjselectednavbar"
                                        :data-index="index"
                                        :style="
                                            'color:' +
                                            (pjselectedindex == index ? '#fff' : '') +
                                            ';background-color: ' +
                                            (pjselectedindex == index ? color : '') +
                                            ';border:' +
                                            (pjselectedindex == index ? 'none' : '')
                                        "
                                        v-for="(item, index) in pjnavbar"
                                        :key="index"
                                    >
                                        {{ item.name }}{{ item.num }}
                                    </view>
                                </view>
                                <view @tap="ytpj" class="graph rel">
                                    <text class="ab ud" v-if="!isytpj"></text>
                                    <icon class="ab ud" :color="color" size="17" style="height: 35rpx; display: inline-block" type="success" v-else></icon>
                                    <text>有图评价</text>
                                </view>
                                <view class="evaluate_list" v-for="(item, index) in storelist" :key="index">
                                    <view class="list_head">
                                        <image mode="aspectFill" :src="item.user_img"></image>
                                    </view>

                                    <view>
                                        <view class="plname">{{ item.name }}</view>
                                        <view class="pltime flex-bet flex-y-center">
                                            <view class="flex-row flex-grow-1 flex-y-center">
                                                <view class="pfimg">
                                                    <view class="kximg">
                                                        <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-star.png"></image>
                                                    </view>
                                                    <view class="sximg" :style="'width: ' + item.stars * 20 + '%'">
                                                        <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-stars.png"></image>
                                                    </view>
                                                </view>
                                            </view>
                                            <view class="flex-grow-0 flex-row flex-y-center">{{ item.time }}</view>
                                        </view>
                                        <view style="margin: 20rpx 0">
                                            <image
                                                @tap="commentPicView"
                                                class="evaluate_image"
                                                :data-id="item.id"
                                                :data-index="index"
                                                :data-picindex="picindex"
                                                mode="aspectFill"
                                                :src="daya_app_url + item1"
                                                v-for="(item1, picindex) in item.img"
                                                :key="picindex"
                                            ></image>
                                        </view>
                                        <view>{{ item.content }}</view>
                                        <view class="sjhf" v-if="item.hf != ''">商家回复：{{ item.hf }}</view>
                                    </view>
                                </view>
                                <view class="jzz" v-if="!mygd">
                                    <image class="Rotation" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/jzz.png"></image>
                                    <view>加载中...</view>
                                </view>
                                <view class="kong" v-if="storelist.length == 0 && mygd">
                                    <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/wushuju.png"></image>
                                    <view>暂无相关数据</view>
                                </view>
                                <view class="jzwb" v-if="mygd">
                                    <view class="hx"></view>
                                    <view class="wz">加载完毕</view>
                                    <view class="hx"></view>
                                </view>
                            </view>
                        </scroll-view>
                    </swiper-item>
                    <swiper-item class="swiper-item3">
                        <scroll-view scrollY class="sjxq" style="height: 100%">
                            <view class="weui-cells weui-cells_after-title">
                                <navigator class="weui-cell weui-cell_access" hoverClass="weui-cell_active" url="">
                                    <view class="weui-cell__bd">商家名称</view>
                                    <view class="weui-cell__ft">{{ store.name }}</view>
                                </navigator>
                                <navigator @tap="maketel" class="weui-cell weui-cell_access" hoverClass="weui-cell_active">
                                    <view class="weui-cell__bd">电话</view>
                                    <view class="weui-cell__ft weui-cell__ft_in-access">{{ paytel }}</view>
                                </navigator>
                                <navigator @tap="location" class="weui-cell weui-cell_access" hoverClass="weui-cell_active">
                                    <view class="weui-cell__bd">地址</view>
                                    <view class="weui-cell__ft weui-cell__ft_in-access">{{ store.address }}</view>
                                </navigator>
                                <navigator class="weui-cell weui-cell_access" hoverClass="weui-cell_active" url="">
                                    <view class="weui-cell__bd">营业时间</view>
                                    <view class="weui-cell__ft">
                                        <text>{{ store.time }}-{{ store.time2 }}</text>
                                        <text style="margin-left: 20rpx">{{ store.time3 }}-{{ store.time4 }}</text>
                                    </view>
                                </navigator>
                            </view>
                            <view class="sjhj">
                                <view>商家环境</view>
                                <view class="xztpul">
                                    <view style="padding: 10px 15px" v-if="store.environment.length == 0">商家暂未上传图片</view>
                                    <block v-else>
                                        <image
                                            @tap="previewhjImage"
                                            class="scimg"
                                            :data-urls="store.environment"
                                            :id="item"
                                            mode="scaleToFill"
                                            :src="item"
                                            v-for="(item, index) in store.environment"
                                            :key="index"
                                        ></image>
                                    </block>
                                </view>
                                <view style="margin-top: 20rpx">商家资质</view>
                                <view class="xztpul">
                                    <view style="padding: 10px 15px" v-if="store.yyzz.length == 0">商家暂未上传资质</view>
                                    <block v-else>
                                        <image
                                            @tap="previewzzImage"
                                            class="scimg"
                                            :data-urls="store.yyzz"
                                            :id="item"
                                            mode="scaleToFill"
                                            :src="item"
                                            v-for="(item, index) in store.yyzz"
                                            :key="index"
                                        ></image>
                                    </block>
                                </view>
                            </view>
                            <view class="sjjj">
                                <view>商家简介</view>
                                <view>
                                    <rich-text :nodes="store.details"></rich-text>
                                </view>
                            </view>
                            <navigator class="jbsj" url="../my/bzzx">
                                <button>举报商家</button>
                            </navigator>
                        </scroll-view>
                    </swiper-item>
                </swiper>
            </view>
            <view class="dbgwc flex-row flex-y-center" v-if="selectedindex == 0">
                <view @tap.stop.prevent="showcart" class="dbgwcl flex-row flex-y-center">
                    <view class="dbgwcl-l flex-grow-0 flex-row flex-y-center" v-if="cart_list.res.length == 0">
                        <image class="gwcimg" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/kgwc.png"></image>
                    </view>
                    <view class="dbgwcl-l flex-grow-0 flex-row flex-y-center" v-else>
                        <image class="gwcimg" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/fgwc.png"></image>
                        <view class="cart_num">{{ cart_list.num }}</view>
                    </view>
                    <view class="dbgwcl-r flex-grow-1">
                        <view class="kname" v-if="cart_list.res.length == 0">购物车是空的</view>
                        <block v-else>
                            <view class="gwcmoney">
                                <text>￥{{ cart_list.money }}</text>
                            </view>
                            <view class="psf">另需配送费{{ psf[0].money }}元</view>
                        </block>
                    </view>
                </view>
                <block v-if="store.is_rest == '2' && time == 1">
                    <view @tap="submit" class="dbgwcr" :style="'background:' + color" v-if="cart_list.money > 0 && cart_list.money >= start_at">{{ subtext }}</view>
                    <view class="dbgwcr" v-else>{{ subtext }}</view>
                </block>
                <view class="dbgwcr" v-else>商家暂未营业</view>
            </view>
        </block>
        <view @tap.stop.prevent="closecart" :class="'share-modal ' + (share_modal_active ? 'active' : '')">
            <view class="share-modal-body">
                <view class="shangpin_bomb">
                    <view class="shangpin1" :style="'border-left:10rpx solid ' + color">购物车</view>
                    <view @tap.stop.prevent="clear" class="sh_clear flex-row flex-y-center" v-if="cart_list.res.length > 0">
                        <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/qksj.png"></image>
                        <view>清空</view>
                    </view>
                </view>
                <view class="splist">
                    <view class="dgsp flex-row flex-y-center" v-for="(item, index) in cart_list.res" :key="index">
                        <view class="dgspleft flex-grow-1">
                            <view class="dgspleft1">{{ item.name }}</view>
                            <view class="dgspleft2">{{ item.spec }}</view>
                        </view>

                        <view class="dgspright flex-row flex-y-center flex-grow-0">
                            <view class="dgspright-l flex-grow-0">￥{{ item.money }}</view>
                            <view class="cartControl flex-grow-1">
                                <view @tap.stop.prevent="gwcdec" class="cartdec" :data-goodid="item.good_id" :data-id="item.id" :data-num="item.num"></view>
                                <view class="goodsnum">{{ item.num }}</view>
                                <view
                                    @tap.stop.prevent="gwcadd"
                                    class="cartadd"
                                    :data-goodid="item.good_id"
                                    :data-id="item.id"
                                    :data-num="item.num"
                                    :style="'background:' + color"
                                ></view>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="dgsp1 flex-row flex-y-center">
                    <view class="dgspleft flex-grow-1">
                        <view class="dgspleft1" v-if="storeset.box_name != ''">{{ storeset.box_name }}</view>
                        <view class="dgspleft1" v-else>包装费</view>
                    </view>
                    <view class="dgspright flex-row flex-y-center flex-grow-0">
                        <view class="dgspright-l flex-grow-0">￥{{ cart_list.box_money }}</view>
                    </view>
                </view>
            </view>
        </view>
        <view @tap="queren" class="fwxxzz" v-if="!fwxy"></view>
        <view class="fwxx" v-if="!fwxy">
            <scroll-view scrollY class="fwxxbd" style="height: 700rpx">
                <view class="sjname flex-col flex-x-center flex-y-center">
                    <view class="headtitle">{{ store.name }}</view>
                    <view class="pfimg">
                        <view class="kximg">
                            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-star.png"></image>
                        </view>
                        <view class="sximg" :style="'width: ' + store.score * 20 + '%'" v-if="store.score != '0'">
                            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-stars.png"></image>
                        </view>
                        <view class="sximg" v-else>
                            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-stars.png"></image>
                        </view>
                    </view>
                    <view class="flex-row flex-y-center" style="flex-wrap: wrap">
                        <text class="sjnametext" style="padding-left: 0">起送￥{{ store.start_at }}</text>
                        <text class="sjnametext">人均￥{{ store.capita }}</text>
                        <text class="sjnametext">配送￥{{ psf[0].money }}</text>
                        <text class="sjnametext" style="border-right: 0">{{ storeset.ps_time }}</text>
                    </view>
                </view>
                <view class="sjgg">
                    <view class="headtitle">商家公告</view>
                    <view class="sjgginfo">{{ store.announcement }}</view>
                </view>
                <view class="yhxx">
                    <view class="headtitle">优惠信息</view>
                    <view class="yhxxmj">
                        <view class="flex-row" v-if="reduction.length > 0">
                            <view class="mj flex-grow-0">减</view>
                            <view class="">
                                <text v-for="(item, index) in reduction" :key="index">满{{ item.full }}减{{ item.reduction }},</text>
                            </view>
                        </view>
                        <view class="flex-row" v-if="storeset.xyh_open == '1'">
                            <view class="xyh flex-grow-0">新</view>
                            <view class="">新用户下单立减{{ storeset.xyh_money }}元</view>
                        </view>
                    </view>
                </view>
            </scroll-view>
        </view>
        <view @tap="gbspgg" @touchmove.stop.prevent="trueFun" class="spggzz" v-if="!spggtoggle"></view>
        <view class="spgg" v-if="!spggtoggle">
            <view class="spggbd">
                <view class="spgg_title">{{ spname }}</view>
                <view @tap="gbspgg" class="x">
                    <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/x.png"></image>
                </view>
                <view class="spgg_ggbd">
                    <block v-for="(attr_group, index) in gg" :key="index">
                        <view class="guige">{{ attr_group.spec_name }}：</view>

                        <view class="ggcontent">
                            <view
                                @tap="attrClick"
                                class="drawer_gg"
                                :data-group-id="attr_group.spec_id"
                                :data-id="item.spec_val_id"
                                :style="
                                    'background:' + (item.checked ? color : '') + ';color:' + (item.checked ? '#fff' : '') + ';border-color:' + (item.checked ? '#fff' : '') + ';'
                                "
                                v-for="(item, index1) in attr_group.spec_val"
                                :key="index1"
                            >
                                {{ item.spec_val_name }}
                            </view>
                        </view>
                    </block>
                </view>
                <view class="spgg_ft flex-bet">
                    <view class="spgg_ftjg">￥{{ gginfo.wm_money }}</view>
                    <view @tap="ggaddcart" class="spgg_ftjr" :style="'background: ' + color">加入购物车</view>
                </view>
            </view>
        </view>
        <view @tap="gbyysj" class="yysjzz" v-if="!yysjtoggle"></view>
        <view class="yysj" v-if="!yysjtoggle">
            <view class="yysjimg">
                <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/wming/wyy.png"></image>
            </view>
            <view class="fyysj">非营业时间，商户休息中</view>
            <view class="kysj">营业时间：{{ store.time }}-{{ store.time2 }} {{ store.time3 }}-{{ store.time4 }}</view>
            <view class="yysjft">
                <view @tap="ckcd" class="ckcd">查看菜单</view>
            </view>
        </view>
        <scroll-view class="spxqmodal" :scrollY="true" v-if="!spxqtoggle">
            <view @tap="gbspxq" class="spxqhead">
                <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/spxqx.png"></image>
            </view>
            <view class="spxqimg">
                <image :src="spxqinfo.logo"></image>
                <view class="spsm" v-if="spxqinfo.content != ''">商品说明：{{ spxqinfo.content }}</view>
            </view>
            <view class="spxx">
                <view class="cplbright1 flex-bet">
                    <view class="cplbright1-l">{{ spxqinfo.name }}</view>
                    <view class="cplbright1-r" v-if="spxqinfo.is_zp == '1'">招牌</view>
                </view>
                <view class="cplbright3 flex-row flex-y-center" style="margin-top: 10rpx">
                    <view class="cplbright31">月销{{ spxqinfo.sales }}笔</view>
                    <view class="cplbright32" v-if="spxqinfo.is_max == '1'">不限量</view>
                    <view class="cplbright32" v-else>库存{{ spxqinfo.inventory }}</view>
                </view>
                <view class="cplbright4 flex-bet">
                    <view class="cplbright4-l flex-grow-1">
                        <text>￥{{ spxqinfo.money }}</text>
                        <text>￥{{ spxqinfo.money2 }}</text>
                    </view>
                    <view class="cartControl flex-grow-0">
                        <view
                            @tap.stop.prevent="ggcartdec"
                            class="cartdec"
                            v-if="spxqinfo.is_gg == '2' && dishes[spxqinfo.catalogSelect].good[spxqinfo.goodindex].quantity > 0"
                        ></view>
                        <view
                            @tap.stop.prevent="cartdec"
                            class="cartdec"
                            :data-goodid="spxqinfo.id"
                            :data-item-index="spxqinfo.goodindex"
                            :data-parentIndex="spxqinfo.catalogSelect"
                            v-if="spxqinfo.is_gg != '2' && dishes[spxqinfo.catalogSelect].good[spxqinfo.goodindex].quantity > 0"
                        ></view>
                        <view class="goodsnum" v-if="dishes[spxqinfo.catalogSelect].good[spxqinfo.goodindex].quantity > 0">
                            {{ dishes[spxqinfo.catalogSelect].good[spxqinfo.goodindex].quantity }}
                        </view>
                        <view
                            @tap.stop.prevent="spggck"
                            class="xgg"
                            :data-goodid="spxqinfo.id"
                            :data-item-index="spxqinfo.goodindex"
                            :data-parentIndex="spxqinfo.catalogSelect"
                            :style="'background:' + color"
                            v-if="spxqinfo.is_gg == '2'"
                        >
                            选规格
                        </view>
                        <view
                            @tap.stop.prevent="cartadd"
                            class="cartadd"
                            :data-goodid="spxqinfo.id"
                            :data-item-index="spxqinfo.goodindex"
                            :data-parentIndex="spxqinfo.catalogSelect"
                            :style="'background:' + color"
                            v-if="spxqinfo.is_gg != '2' && spxqinfo.inventory > 0"
                        ></view>
                    </view>
                    <view class="xgg" style="background: #cccccc" v-if="spxqinfo.is_gg != '2' && spxqinfo.inventory <= 0">已售完</view>
                </view>
            </view>
            <view class="spxq">商品详情</view>
            <view class="spxqv">
                <rich-text :nodes="spxqinfo.details"></rich-text>
            </view>
        </scroll-view>
        <view class="tjhbzz" v-if="hbtoggle"></view>
        <view :class="'tjhbcell flex-col flex-y-center ' + (hbtoggle ? 'tjhb-show' : 'tjhb-hide')" v-if="hbtoggle">
            <view class="tjhbbd">
                <image class="tjhbbdimg" mode="widthFix" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/hbhead.png"></image>
                <view class="hbtitle1">送你 {{ wlqyhq.length }} 个红包</view>
                <view class="hbtitle2">赶快下单使用吧 !</view>
                <view class="tjhbbdcv">
                    <view class="tjhbbdc">
                        <view class="bbcell flex-row" v-for="(item, index) in wlqyhq" :key="index">
                            <view class="bbcelll flex-col flex-x-center flex-y-center">
                                <view class="bby1"></view>
                                <view class="bby2"></view>
                                <view class="bbm">
                                    <text>￥</text>
                                    {{ item.reduce }}
                                </view>
                                <view class="bbf">满{{ item.full }}可用</view>
                            </view>

                            <view class="bbcellr flex-grow-1 flex-row flex-y-center">
                                <view class="flex-grow-1 flex-col flex-x-center">
                                    <view class="bbname gobyndsingle">{{ item.name }}</view>
                                    <view class="bbtime">有效期至:{{ item.end_time }}</view>
                                </view>
                                <view class="flex-grow-0 flex-col flex-x-center flex-y-center">
                                    <view class="bbtype" v-if="item.type == '1'">店外可用</view>
                                    <view class="bbtype" v-if="item.type == '2'">店内可用</view>
                                    <view class="bbtype" v-if="item.type == '3'">店内店外</view>
                                    <view @tap="ljlq" class="bblq" :data-qid="item.id" v-if="item.state == '2' && item.stock != '0'">立即领取</view>
                                    <view @tap="qsy" class="bblq bbsy" :data-type="item.type" v-if="item.state == '1'">立即使用</view>
                                    <view class="bblq bbqg" v-if="item.state == '2' && item.stock == '0'">已经抢光</view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
            </view>
            <image @tap="closehbtoggle" class="tjhbft" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/gbpd.png"></image>
        </view>
        <gettel v-if="userinfo && !userinfo.user_tel && xtxx.is_tel == 1"></gettel>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var qqmapsdk;
var app = getApp();
var util = require('../../utils/util.js');
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
          show_subs:false,
          store_subs: [],
             daya_app_url: '',
            isloading: true,
            store_id: '1',
            navbar: ['外卖', '评价', '详情'],
            selectedindex: 0,
            catalogSelect: 0,
            share_modal_active: false,
            color: '',
            fwxy: true,
            cpjzz: true,
            spggtoggle: true,
            yysjtoggle: true,
            spxqtoggle: true,
            gg: [],
            storeyyzz: [],
            pjselectedindex: 0,
            isytpj: false,
            pagenum: 1,
            storelist: [],
            bfstorelist: [],
            mygd: false,
            jzgd: true,
            loadMore: true,
            loadindex: 1,
            scroll: 'scroll',
            iszk: false,
            params: {},
            weizhi: '',
            slider: '',
            time: 0,
            psf: '',
            reduction: '',

            store: {
                name: '',
                logo: '',
                announcement: '',
                start_at: '',
                sales: '',
                address: '',
                time: '',
                time2: '',
                time3: '',
                time4: '',
                environment: [],
                yyzz: [],
                details: '',
                is_rest: '',
                score: 0,
                capita: ''
            },

            storeset: {
                top_style: '',
                ps_time: '',
                ps_mode: '',
                ps_jl: '',
                xyh_open: '',
                xyh_money: '',
                box_name: ''
            },

            start_at: '',

            xtxx: {
                hygn: '',
                is_tel: 0
            },

            paytel: '',

            userinfo: {
                user_tel: ''
            },

            dataheith: '',

            cart_list: {
                res: [],
                num: '',
                money: '',
                box_money: ''
            },

            dishes: '',
            navzdoffsetTop: '',
            hbtoggle: false,
            iszd: false,
            isjzz: false,
            pjnavbar: '',
            Coupons: '',
            wlqyhq: '',

            spxqinfo: {
                logo: '',
                content: '',
                name: '',
                is_zp: '',
                sales: '',
                is_max: '',
                inventory: '',
                money: '',
                money2: '',
                is_gg: '',
                id: '',
                goodindex: '',
                catalogSelect: '',
                details: ''
            },

            spname: '',

            gginfo: {
                wm_money: ''
            },

            parentindex: '',
            toType: '',
            toView: '',
            subtext: '',


            parentIndex: '',

            disheitem: {
                good: [],
                id: ''
            },

            goodindex: 0,

            gooditem: {
                id: '',
                logo: '',
                name: '',
                is_zp: '',
                content: '',
                sales: '',
                restrict_num: '',
                start_num: '',
                vip_money: '',
                is_gg: '',
                money: '',
                money2: 0,
                quantity: 0,
                inventory: 0
            },

            picindex: 0,
            url: '',
            money: '',

            attr_group: {
                spec_name: '',
                spec_id: '',
                spec_val: []
            },

            quantity: 0,
            good: ''
        };
    },
    onLoad: function (t) {
        this.onLoadClone3389(t);
      // this.load_store_subs();
    },
    onReady: function () {

    },
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onShareAppMessage: function () {
        return {
            title: this.store.name,
            path: '/ymq_canyino2o/pages/Liar/loginindex',
            success: function (t) {},
            fail: function (t) {}
        };
    },
    onShareTimeline: function () {
        return {
            title: this.store.name,
            path: '/ymq_canyino2o/pages/Liar/loginindex',
            success: function (t) {},
            fail: function (t) {}
        };
    },
    methods: {
      gotoStore(id) {
        uni.navigateTo({
          url: '/ymq_canyino2o/pages/seller/index?sjid=' + id
        })
      },
      close_store_subs_drawer() {
        //当前店铺 关闭订阅消息弹窗,并且缓存起来,时间1小时过期
        let sjid=getApp().globalData.sjid
        //当前时间加1小时
        let time = new Date().getTime() + 1 * 60 * 60 * 1000
        uni.setStorageSync('store_subs_' + sjid, time)
        this.store_subs = [];
        // uni.showToast({
        //   title: '1小时不再提醒关联店铺',
        //   icon: 'none'
        // })
      },
      load_store_subs: function () {
        console.log("getApp().globalData.sjid", getApp().globalData.sjid)
        if (getApp().globalData.sjid == null || getApp().globalData.sjid == undefined || getApp().globalData.sjid == '') {
          return
        }

        let sjid=getApp().globalData.sjid
        //获取缓存,如果缓存不存在,或者缓存值小于了当前时间戳,则显示关联店铺
        let time = uni.getStorageSync('store_subs_' + sjid)
        if (time == null || time == undefined || time < new Date().getTime()) {
          this.show_subs = true;
        }

        var that = this
        app.globalData.util.request({
          url: 'entry/wxapp/store_subs',
          data:{
            store_id: getApp().globalData.sjid
          },
          cachetime: '0',
          success: function (a) {
            that.store_subs=a.data.data
          }
        })
      },
        onLoadClone3389: function (t) {
            qqmapsdk = new QQMapWX({
                key: getApp().globalData.xtxx.map_key
            });
            console.log('options', t);
            app.globalData.setNavigationBarColor(this);
            this.appPageOnLoad(app);
            this.setData({
                store_id: getApp().globalData.sjid
            });
            this.setData({
                params: {
                    store_id: getApp().globalData.sjid,
                    type: '全部',
                    img: ''
                }
            });
            this.getstorelist();
            var that = this;
            var c = that.store_id;
            var g = util.formatTime(new Date()).slice(11, 16);
            app.globalData.util.request({
                url: 'entry/wxapp/StoreInfo',
                cachetime: '0',

                data: {
                    store_id: c,
                    type: 2
                },

                success: function (t) {
                    console.log(t.data);
                    uni.setNavigationBarTitle({
                        title: t.data.store.name
                    });
                    if ('2' == t.data.storeset.top_style) {
                        uni.getLocation({
                            type: 'wgs84',

                            success: function (t) {
                                var a = t.latitude;
                                var e = t.longitude;
                                var o = a + ',' + e;
                                console.log(o);
                                qqmapsdk.reverseGeocoder({
                                    location: {
                                        latitude: a,
                                        longitude: e
                                    },

                                    coord_type: 1,

                                    success: function (t) {
                                        t.result.ad_info.location;
                                        console.log(t);
                                        console.log(t.result.formatted_addresses.recommend);
                                        console.log('坐标转地址后的经纬度：', t.result.ad_info.location);
                                        that.setData({
                                            weizhi: t.result.formatted_addresses.recommend
                                        });
                                    },

                                    fail: function (t) {
                                        console.log(t);
                                    },

                                    complete: function (t) {
                                        console.log(t);
                                    }
                                });
                            },

                            fail: function () {
                                uni.getSetting({
                                    success: function (t) {
                                        console.log(t);
                                        if (0 == t.authSetting['scope.userLocation']) {
                                            uni.showModal({
                                                title: '提示',
                                                content: '您点击了拒绝授权,无法正常使用功能，点击确定重新获取授权。',
                                                showCancel: false,

                                                success: function (t) {
                                                    if (t.confirm) {
                                                        console.log('用户点击确定');
                                                        uni.openSetting({
                                                            success: function (t) {
                                                                t.authSetting['scope.userLocation'];
                                                                that.onLoadClone3389({});
                                                            }
                                                        });
                                                    }
                                                }
                                            });
                                        }
                                    }
                                });
                            },

                            complete: function (t) {}
                        });
                        app.globalData.util.request({
                            url: 'entry/wxapp/StoreAd',
                            cachetime: '0',

                            data: {
                                store_id: c
                            },

                            success: function (t) {
                                console.log(t.data);
                                that.setData({
                                    slider: t.data
                                });
                            }
                        });
                    }
                    var a = t.data.store.time;
                    var e = t.data.store.time2;
                    var o = t.data.store.time3;
                    var s = t.data.store.time4;
                    var i = t.data.store.is_rest;
                    console.log('当前的系统时间为' + g);
                    console.log('商家的营业时间从' + a + '至' + e, o + '至' + s);
                    if (1 == i) {
                        that.setData({
                            yysjtoggle: false
                        });
                        console.log('商家正在休息' + i);
                    } else {
                        console.log('商家正在营业' + i);
                    }
                    if (a < s) {
                        if ((a < g && g < e) || (o < g && g < s) || (o < g && s < o)) {
                            console.log('商家正常营业');
                            that.setData({
                                time: 1
                            });
                        } else {
                            if (g < a || (e < g && g < o)) {
                                console.log('商家还没开店呐，稍等一会儿可以吗？');
                                that.setData({
                                    time: 2,
                                    yysjtoggle: false
                                });
                            } else {
                                if (s < g) {
                                    console.log('商家以及关店啦，明天再来吧');
                                    that.setData({
                                        time: 3,
                                        yysjtoggle: false
                                    });
                                }
                            }
                        }
                    } else {
                        if (s < a) {
                            if ((a < g && g < e) || (o < g && s < g) || (g < o && g < s)) {
                                console.log('商家正常营业'),
                                    that.setData({
                                        time: 1
                                    });
                            } else {
                                if (g < a || (e < g && g < o)) {
                                    console.log('商家还没开店呐，稍等一会儿可以吗？'),
                                        that.setData({
                                            time: 2,
                                            yysjtoggle: false
                                        });
                                } else {
                                    s < g &&
                                        (console.log('商家以及关店啦，明天再来吧'),
                                        that.setData({
                                            time: 3,
                                            yysjtoggle: false
                                        }));
                                }
                            }
                        }
                    }
                    for (var n = 0; n < t.data.store.environment.length; n++) {
                        t.data.store.environment[n] = that.daya_app_url + t.data.store.environment[n];
                    }
                    for (var r = 0; r < t.data.store.yyzz.length; r++) {
                        t.data.store.yyzz[r] = that.daya_app_url + t.data.store.yyzz[r];
                    }
                    if ('' != t.data.storeset.wm_name) {
                        that.setData({
                            navbar: [t.data.storeset.wm_name, '评价', '详情']
                        });
                    }
                    var d = t.data.store.tel;
                    that.setData({
                        psf: t.data.psf,
                        reduction: t.data.reduction,
                        store: t.data.store,
                        storeset: t.data.storeset,
                        start_at: t.data.store.start_at,
                        xtxx: getApp().globalData.xtxx,
                        paytel:
                            '1' == getApp().globalData.xtxx.is_pay && 0 < Number(getApp().globalData.xtxx.pay_money) ? d.substring(0, 3) + '****' + d.substring(d.length - 4) : d
                    });
                }
            });
            app.globalData.getUserInfo(function (t) {
                app.globalData.util.request({
                    url: 'entry/wxapp/DelCar',
                    cachetime: '0',

                    data: {
                        user_id: t.id,
                        store_id: that.store_id
                    },

                    success: function (t) {
                        console.log(t.data);
                    }
                });
                var a = util.formatTime(new Date()).substring(0, 10).replace(/\//g, '-');
                console.log(t, a);
                that.setData({
                    userinfo: t
                });
                if ('' != t.dq_time && t.dq_time >= a.toString()) {
                    that.setData({
                        iszk: true
                    });
                }
                var d = uni.getStorageSync('users').id;
                var c = that.store_id;
                console.log('uid', d);
                app.globalData.util.request({
                    url: 'entry/wxapp/Hot',
                    cachetime: '0',

                    data: {
                        store_id: c,
                        type: 2
                    },

                    success: function (t) {
                        if (0 < t.data.length) {
                            var r = new Array();
                            var a = new Object();
                            a.good = t.data;
                            a.type_name = '热销';
                            a.id = '0';
                            r.push(a);
                            app.globalData.util.request({
                                url: 'entry/wxapp/DishesList',
                                cachetime: '0',

                                data: {
                                    store_id: c,
                                    type: 2
                                },

                                success: function (t) {
                                  console.log("t.data",t.data)
                                    for (var i = r.concat(t.data), a = 0; a < i.length; a++) {
                                        for (var e = 0; e < i[a].good.length; e++) {
                                            i[a].good[e].quantity = Number(i[a].good[e].quantity);
                                        }
                                    }
                                    for (var o = 0, s = [], n = 0; n < i.length; n++) {
                                        o += 105 * i[n].good.length;
                                        s.push(o);
                                    }
                                    that.setData({
                                        cpjzz: false,
                                        dataheith: s
                                    });
                                    app.globalData.util.request({
                                        url: 'entry/wxapp/MyCar',
                                        cachetime: '0',

                                        data: {
                                            store_id: c,
                                            user_id: d
                                        },

                                        success: function (t) {
                                            for (var a = t.data.res, e = 0; e < a.length; e++) {
                                                for (var o = 0; o < i.length; o++) {
                                                    for (var s = 0; s < i[o].good.length; s++) {
                                                        if (a[e].good_id == i[o].good[s].id) {
                                                            i[o].good[s].quantity = i[o].good[s].quantity + Number(a[e].num);
                                                        }
                                                    }
                                                }
                                            }
                                            that.setData({
                                                cart_list: t.data,
                                                dishes: i,
                                                isloading: false
                                            });
                                            that.subText();
                                            that.CouponsFun();
                                        }
                                    });
                                }
                            });
                        } else {
                            app.globalData.util.request({
                                url: 'entry/wxapp/DishesList',
                                cachetime: '0',

                                data: {
                                    store_id: c,
                                    type: 2
                                },

                                success: function (t) {
                                    for (var i = t.data, a = 0; a < i.length; a++) {
                                        for (var e = 0; e < i[a].good.length; e++) {
                                            i[a].good[e].quantity = Number(i[a].good[e].quantity);
                                        }
                                    }
                                    for (var o = 0, s = [], n = 0; n < i.length; n++) {
                                        o += 105 * i[n].good.length;
                                        s.push(o);
                                    }
                                    that.setData({
                                        cpjzz: false,
                                        dataheith: s
                                    });
                                    app.globalData.util.request({
                                        url: 'entry/wxapp/MyCar',
                                        cachetime: '0',

                                        data: {
                                            store_id: c,
                                            user_id: d
                                        },

                                        success: function (t) {
                                            for (var a = t.data.res, e = 0; e < a.length; e++) {
                                                for (var o = 0; o < i.length; o++) {
                                                    for (var s = 0; s < i[o].good.length; s++) {
                                                        if (a[e].good_id == i[o].good[s].id) {
                                                            i[o].good[s].quantity = i[o].good[s].quantity + Number(a[e].num);
                                                        }
                                                    }
                                                }
                                            }
                                            that.setData({
                                                cart_list: t.data,
                                                dishes: i,
                                                isloading: false
                                            });
                                            that.subText();
                                            that.CouponsFun();
                                        }
                                    });
                                }
                            });
                        }
                    }
                });
            });
            uni.getSystemInfo({
                success: function (t) {
                    console.log(t);
                    that.setData({
                        navzdoffsetTop: t.windowHeight / 4
                    });
                }
            });
        },

        closehbtoggle: function () {
            this.setData({
                hbtoggle: false
            });
        },

        tozd: function (t) {
            this.setData({
                iszd: false
            });
        },

        previewzzImage: function (t) {
            var a = t.currentTarget.dataset.urls;
            var e = t.currentTarget.id;
            uni.previewImage({
                current: e,
                urls: a
            });
        },

        previewhjImage: function (t) {
            var a = t.currentTarget.dataset.urls;
            var e = t.currentTarget.id;
            uni.previewImage({
                current: e,
                urls: a
            });
        },

        cartaddformSubmit: function (t) {
            console.log('formid', t.detail.formId);
            var a = uni.getStorageSync('users').id;
            app.globalData.util.request({
                url: 'entry/wxapp/AddFormId',
                cachetime: '0',
                data: {
                    user_id: a,
                    form_id: t.detail.formId
                },
                success: function (t) {
                    console.log(t.data);
                }
            });
        },

        commentPicView: function (t) {
            console.log(t);
            var a = this.storelist;
            var e = [];
            var o = t.currentTarget.dataset.index;
            var s = t.currentTarget.dataset.picindex;
            var i = t.currentTarget.dataset.id;
            console.log(o, s, i);
            if (i == a[o].id) {
                var n = a[o].img;
                for (var r in n) {
                    e.push(this.daya_app_url + n[r]);
                }
                uni.previewImage({
                    current: this.daya_app_url + n[s],
                    urls: e
                });
            }
        },

        ytpj: function () {
            var t = this.params;
            if (this.isytpj) {
                t.img = '';
            } else {
                t.img = '1';
            }
            this.setData({
                pagenum: 1,
                storelist: [],
                bfstorelist: [],
                mygd: false,
                jzgd: true,
                isytpj: !this.isytpj,
                params: t
            });
            this.getstorelist();
        },

        pjselectednavbar: function (t) {
            console.log(t);
            var a = this.params;
            if (0 == t.currentTarget.dataset.index) {
                a.type = '全部';
            }
            if (1 == t.currentTarget.dataset.index) {
                a.type = '1';
            }
            if (2 == t.currentTarget.dataset.index) {
                a.type = '2';
            }
            this.setData({
                pagenum: 1,
                storelist: [],
                bfstorelist: [],
                mygd: false,
                jzgd: true,
                pjselectedindex: t.currentTarget.dataset.index,
                params: a
            });
            this.getstorelist();
        },

        getstorelist: function () {
            var that = this;
            var s = that.pagenum;
            that.params.page = s;
            that.params.pagesize = 10;
            console.log(s, that.params);
            that.setData({
                isjzz: true
            });
            app.globalData.util.request({
                url: 'entry/wxapp/AssessList',
                cachetime: '0',
                data: that.params,
                success: function (t) {
                    console.log('分页返回的商家列表数据', t.data);
                    var a = [
                        {
                            name: '全部',
                            num: t.data.all
                        },
                        {
                            name: '满意',
                            num: t.data.ok
                        },
                        {
                            name: '不满意',
                            num: t.data.no
                        }
                    ];
                    var e = that.bfstorelist;
                    e = (function (t) {
                        for (var a = [], e = 0; e < t.length; e++) {
                            if (-1 == a.indexOf(t[e])) {
                                a.push(t[e]);
                            }
                        }
                        return a;
                    })((e = e.concat(t.data.assess)));
                    that.setData({
                        storelist: e,
                        bfstorelist: e,
                        pjnavbar: a
                    });
                    if (t.data.assess.length < 10) {
                        that.setData({
                            mygd: true,
                            jzgd: true,
                            isjzz: false
                        });
                    } else {
                        that.setData({
                            jzgd: true,
                            pagenum: s + 1,
                            isjzz: false
                        });
                    }
                    console.log(e);
                }
            });
        },

        CouponsFun: function () {
            var that = this;
            var t = uni.getStorageSync('users').id;
            var a = that.store_id;
            app.globalData.util.request({
                url: 'entry/wxapp/Coupons',
                cachetime: '0',
                data: {
                    store_id: a,
                    user_id: t
                },
                success: function (t) {
                    console.log(t.data);
                    for (var a = [], e = [], o = 0; o < t.data.length; o++) {
                        if ('2' != t.data[o].type && '0' != t.data[o].stock) {
                            a.push(t.data[o]);
                        }
                        if ('2' == t.data[o].state && '2' != t.data[o].type && '0' != t.data[o].stock) {
                            e.push(t.data[o]);
                        }
                    }
                    that.setData({
                        Coupons: a,
                        wlqyhq: e,
                        hbtoggle: 0 < e.length
                    });
                    console.log(e);
                }
            });
        },

        ljlq: function (t) {
            console.log(t.currentTarget.dataset.qid);
            var that = this;
            var e = uni.getStorageSync('users').id;
            uni.showLoading({
                title: '正在加载',
                mask: true
            });
            app.globalData.util.request({
                url: 'entry/wxapp/LqCoupons',
                cachetime: '0',
                data: {
                    user_id: e,
                    coupon_id: t.currentTarget.dataset.qid
                },
                success: function (t) {
                    console.log(t);
                    if ('1' == t.data) {
                        uni.showLoading({
                            title: '领取成功',
                            mask: true
                        });
                        setTimeout(function () {
                            that.CouponsFun();
                        }, 1000);
                    }
                }
            });
        },

        submit: function () {
            var t = this.userinfo;
            console.log(t);
            if ('' == t.img || '' == t.name) {
                uni.navigateTo({
                    url: '/ymq_canyino2o/pages/my/userinfo' // ../smdc/getdl
                });
            } else {
                uni.navigateTo({
                    url: '../takeout/takeoutform?storeid=' + this.store_id
                });
            }
        },

        lookck: function () {
            this.setData({
                fwxy: false
            });
        },

        queren: function () {
            this.setData({
                fwxy: true
            });
        },

        spxqck: function (t) {
            var a = t.currentTarget.dataset.itemIndex;
            var e = t.currentTarget.dataset.parentindex;
            var o = (this.dishes, this.cart_list.res, t.currentTarget.dataset.goodid, this.dishes[e].good[a]);
            uni.getStorageSync('users').id;
            this.store_id;
            o.goodindex = a;
            o.catalogSelect = e;
            this.setData({
                spxqinfo: o,
                spxqtoggle: false
            });
        },

        ckcd: function () {
            this.setData({
                yysjtoggle: true
            });
        },

        gdsh: function () {
            uni.navigateBack({});
        },

        gbspxq: function () {
            this.setData({
                spxqtoggle: true
            });
        },

        ggcartdec: function () {
            var that = this;
            uni.showModal({
                title: '提示',
                content: '多规格商品请在购物车中删除对应的规格商品！',
                success: function (t) {
                    that.setData({
                        share_modal_active: true
                    });
                }
            });
        },

        gwcdec: function (t) {
            for (var that = this, s = this.dishes, i = t.currentTarget.dataset.goodid, a = t.currentTarget.dataset.id, e = 0; e < s.length; e++) {
                for (var n = 0; n < s[e].good.length; n++) {
                    if (s[e].good[n].id == i) {
                        console.log(s[e].good[n]);
                        var r = 1;
                        if (Number(s[e].good[n].start_num) == Number(t.currentTarget.dataset.num)) {
                            r = Number(s[e].good[n].start_num);
                        }
                        var d = Number(t.currentTarget.dataset.num) - r;
                        console.log(d, r);
                        uni.showLoading({
                            title: '正在加载',
                            mask: true
                        });
                        app.globalData.util.request({
                            url: 'entry/wxapp/UpdCar',
                            cachetime: '0',
                            data: {
                                num: d,
                                id: a
                            },
                            success: function (t) {
                                console.log(t);
                                if ('1' == t.data) {
                                    for (var a = 0; a < s.length; a++) {
                                        for (var e = 0; e < s[a].good.length; e++) {
                                            if (s[a].good[e].id == i) {
                                                s[a].good[e].quantity = s[a].good[e].quantity - r;
                                            }
                                        }
                                    }
                                    that.setData({
                                        dishes: s
                                    });
                                    that.gwcreload();
                                }
                                if ('超出库存!' == t.data) {
                                    uni.showModal({
                                        title: '提示',
                                        content: '超出库存!'
                                    });
                                }
                            }
                        });
                    }
                }
            }
        },

        gwcadd: function (t) {
            var that = this;
            var s = this.dishes;
            var i = t.currentTarget.dataset.goodid;
            var a = Number(t.currentTarget.dataset.num) + 1;
            var e = t.currentTarget.dataset.id;
            uni.showLoading({
                title: '正在加载',
                mask: true
            });
            app.globalData.util.request({
                url: 'entry/wxapp/UpdCar',
                cachetime: '0',
                data: {
                    num: a,
                    id: e
                },
                success: function (t) {
                    console.log(t);
                    if ('1' == t.data) {
                        for (var a = 0; a < s.length; a++) {
                            for (var e = 0; e < s[a].good.length; e++) {
                                if (s[a].good[e].id == i) {
                                    s[a].good[e].quantity++;
                                }
                            }
                        }
                        that.setData({
                            dishes: s
                        });
                        that.gwcreload();
                    } else {
                        if ('超出库存!' == t.data) {
                            uni.showModal({
                                title: '提示',
                                content: '库存不足!请重新选择'
                            });
                        } else {
                            if ('超出购买限制!' == t.data) {
                                uni.showModal({
                                    title: '提示',
                                    content: '超出购买限制!'
                                });
                            }
                        }
                    }
                }
            });
        },

        cartdec: function (t) {
            for (
                var a = t.currentTarget.dataset.itemIndex,
                    e = t.currentTarget.dataset.parentindex,
                    o = this.dishes,
                    s = this.cart_list.res,
                    i = t.currentTarget.dataset.goodid,
                    that = this,
                    r = this.dishes[e].good[a],
                    d = (uni.getStorageSync('users').id, this.store_id, 0);
                d < s.length;
                d++
            ) {
                if (s[d].good_id == i) {
                    var c = 1;
                    if (Number(r.start_num) == Number(s[d].num)) {
                        c = Number(r.start_num);
                    }
                    var l = Number(s[d].num) - c;
                    var g = s[d].id;
                    console.log(s[d], l, g);
                    uni.showLoading({
                        title: '正在加载',
                        mask: true
                    });
                    app.globalData.util.request({
                        url: 'entry/wxapp/UpdCar',
                        cachetime: '0',
                        data: {
                            num: l,
                            id: g
                        },
                        success: function (t) {
                            console.log(t);
                            if ('1' == t.data) {
                                for (var a = 0; a < o.length; a++) {
                                    for (var e = 0; e < o[a].good.length; e++) {
                                        if (o[a].good[e].id == i) {
                                            o[a].good[e].quantity = o[a].good[e].quantity - c;
                                        }
                                    }
                                }
                                that.setData({
                                    dishes: o
                                });
                                that.gwcreload();
                            }
                            if ('超出库存!' == t.data) {
                                uni.showModal({
                                    title: '提示',
                                    content: '超出库存!'
                                });
                            }
                        }
                    });
                }
            }
        },

        isInArray: function (t, a) {
            for (var e = 0; e < t.length; e++) {
                if (a === t[e].good_id) {
                    return true;
                }
            }
            return false;
        },

        cartadd: function (t) {
            var a = t.currentTarget.dataset.itemIndex;
            var e = t.currentTarget.dataset.parentindex;
            var o = this.dishes;
            var s = this.cart_list.res;
            var i = t.currentTarget.dataset.goodid;
            var that = this;
            var r = this.dishes[e].good[a];
            var d = uni.getStorageSync('users').id;
            var c = this.store_id;
            var l = '1' == getApp().globalData.xtxx.hygn && this.iszk && '0.00' != r.vip_money ? 1 : 0;
            var g = 1;
            '0' == r.start_num || that.isInArray(s, i) || (g = Number(r.start_num));
            console.log(g);
            uni.showLoading({
                title: '正在加载',
                mask: true
            });
            app.globalData.util.request({
                url: 'entry/wxapp/AddCar',
                cachetime: '0',
                data: {
                    money: l ? r.vip_money : r.money,
                    good_id: i,
                    store_id: c,
                    user_id: d,
                    num: g,
                    spec: '',
                    combination_id: '',
                    box_money: r.box_money
                },
                success: function (t) {
                    console.log(t);
                    if ('1' == t.data) {
                        for (var a = 0; a < o.length; a++) {
                            for (var e = 0; e < o[a].good.length; e++) {
                                if (o[a].good[e].id == i) {
                                    o[a].good[e].quantity = g + o[a].good[e].quantity;
                                }
                            }
                        }
                        that.setData({
                            dishes: o
                        });
                        that.gwcreload();
                    } else {
                        if ('超出库存!' == t.data) {
                            uni.showModal({
                                title: '提示',
                                content: '库存不足!请重新选择'
                            });
                        } else {
                            if ('超出购买限制!' == t.data) {
                                uni.showModal({
                                    title: '提示',
                                    content: '超出购买限制!'
                                });
                            }
                        }
                    }
                }
            });
        },

        spggck: function (t) {
            var d = t.currentTarget.dataset.itemIndex;
            var c = t.currentTarget.dataset.parentindex;
            var l = t.currentTarget.dataset.goodid;
            var that = this;
            console.log(d, c, l);
            app.globalData.util.request({
                url: 'entry/wxapp/GoodInfo',
                cachetime: '0',
                data: {
                    good_id: l
                },
                success: function (t) {
                    console.log(t.data);
                    var a = t.data.spec;
                    var e = t.data.name;
                    for (var o in a) {
                        for (var s in a[o].spec_val) {
                            a[o].spec_val[s].checked = 0 == s;
                        }
                    }
                    that.setData({
                        gg: a,
                        spname: e
                    });
                    console.log(a);
                    var i = [];
                    var n = true;
                    for (var o in a) {
                        var r = false;
                        for (var s in a[o].spec_val) {
                            if (a[o].spec_val[s].checked) {
                                i.push(a[o].spec_val[s].spec_val_name);
                                r = true;
                                break;
                            }
                        }
                        if (!r) {
                            n = false;
                            break;
                        }
                    }
                    console.log(l, i, i.toString());
                    if (n) {
                        uni.showLoading({
                            title: '正在加载',
                            mask: true
                        });
                        app.globalData.util.request({
                            url: 'entry/wxapp/GgZh',
                            cachetime: '0',
                            data: {
                                combination: i.toString(),
                                good_id: l
                            },
                            success: function (t) {
                                console.log(t);
                                that.setData({
                                    spggtoggle: false,
                                    gginfo: t.data,
                                    itemIndex: d,
                                    parentindex: c
                                });
                            }
                        });
                    }
                }
            });
        },

        attrClick: function (t) {
            var that = this;
            var e = this.gginfo.good_id;
            var o = t.target.dataset.groupId;
            var s = t.target.dataset.id;
            var i = that.gg;
            for (var n in (console.log(o, s, i), i)) {
                if (i[n].spec_id == o) {
                    for (var r in i[n].spec_val) {
                        if (i[n].spec_val[r].spec_val_id == s) {
                            i[n].spec_val[r].checked = true;
                        } else {
                            i[n].spec_val[r].checked = false;
                        }
                    }
                }
            }
            that.setData({
                gg: i
            });
            var d = [];
            var c = true;
            for (var n in i) {
                var l = false;
                for (var r in i[n].spec_val) {
                    if (i[n].spec_val[r].checked) {
                        d.push(i[n].spec_val[r].spec_val_name);
                        l = true;
                        break;
                    }
                }
                if (!l) {
                    c = false;
                    break;
                }
            }
            console.log(e, d, d.toString());
            if (c) {
                uni.showLoading({
                    title: '正在加载',
                    mask: true
                });
                app.globalData.util.request({
                    url: 'entry/wxapp/GgZh',
                    cachetime: '0',
                    data: {
                        combination: d.toString(),
                        good_id: e
                    },
                    success: function (t) {
                        console.log(t);
                        that.setData({
                            gginfo: t.data
                        });
                    }
                });
            }
        },

        ggaddcart: function () {
            this.itemIndex;
            this.parentindex;
            var o = this.dishes;
            var that = this;
            var i = this.gginfo;
            var t = uni.getStorageSync('users').id;
            var a = this.gg;
            var e = this.store_id;
            var n = [];
            var r = true;
            for (var d in a) {
                var c = false;
                for (var l in a[d].spec_val) {
                    if (a[d].spec_val[l].checked) {
                        n.push(a[d].spec_name + ':' + a[d].spec_val[l].spec_val_name);
                        c = true;
                        break;
                    }
                }
                if (!c) {
                    r = false;
                    break;
                }
            }
            if (r) {
                uni.showLoading({
                    title: '正在加载',
                    mask: true
                });
                app.globalData.util.request({
                    url: 'entry/wxapp/AddCar',
                    cachetime: '0',
                    data: {
                        money: i.wm_money,
                        good_id: i.good_id,
                        store_id: e,
                        user_id: t,
                        num: 1,
                        spec: n.toString(),
                        combination_id: i.id,
                        box_money: i.box_money
                    },
                    success: function (t) {
                        console.log(t);
                        if ('1' == t.data) {
                            for (var a = 0; a < o.length; a++) {
                                for (var e = 0; e < o[a].good.length; e++) {
                                    if (o[a].good[e].id == i.good_id) {
                                        o[a].good[e].quantity++;
                                    }
                                }
                            }
                            that.setData({
                                dishes: o
                            });
                            that.gwcreload();
                            that.setData({
                                spggtoggle: true
                            });
                        }
                        if ('超出库存!' == t.data) {
                            uni.showModal({
                                title: '提示',
                                content: '暂无库存!请选择其他规格或商品'
                            });
                        }
                    }
                });
            }
        },

        gwcreload: function () {
            this.dishes;
            var that = this;
            var t = uni.getStorageSync('users').id;
            var e = this.store_id;
            app.globalData.util.request({
                url: 'entry/wxapp/MyCar',
                cachetime: '0',
                data: {
                    store_id: e,
                    user_id: t
                },
                success: function (t) {
                    console.log(t);
                    that.setData({
                        cart_list: t.data
                    });
                    that.subText();
                }
            });
        },

        gbspgg: function () {
            this.setData({
                spggtoggle: true
            });
        },

        gbyysj: function () {
            this.setData({
                yysjtoggle: true
            });
        },

        selectednavbar: function (t) {
            console.log(t);
            this.setData({
                selectedindex: t.currentTarget.dataset.index
            });
        },

        scrolltolower: function () {
            var s = this.dishes;
            var that = this;
            var e = uni.getStorageSync('users').id;
            var o = that.store_id;
            var n = this.loadindex;
            console.log(s, e, o, n);
            that.setData({
                loadMore: false
            });
            if (n < s.length && 0 == s[n].good.length) {
                var t = s[n].id;
                console.log('还没加载过数据', t);
                that.setData({
                    cpjzz: true
                });
                app.globalData.util.request({
                    url: 'entry/wxapp/Dishes',
                    cachetime: '0',
                    data: {
                        type_id: t,
                        type: 2
                    },
                    success: function (t) {
                        console.log(t.data);
                        for (var a = 0; a < t.data.length; a++) {
                            t.data[a].quantity = Number(t.data[a].quantity);
                        }
                        s[n].good = t.data;
                        app.globalData.util.request({
                            url: 'entry/wxapp/MyCar',
                            cachetime: '0',
                            data: {
                                store_id: o,
                                user_id: e
                            },
                            success: function (t) {
                                console.log(t);
                                for (var a = t.data.res, e = 0; e < a.length; e++) {
                                    for (var o = 0; o < s[n].good.length; o++) {
                                        if (a[e].good_id == s[n].good[o].id) {
                                            s[n].good[o].quantity = s[n].good[o].quantity + Number(a[e].num);
                                        }
                                    }
                                }
                                that.setData({
                                    dishes: s,
                                    loadindex: n + 1,
                                    loadMore: true
                                });
                                if (n == s.length - 1) {
                                    console.log('alldie');
                                    that.setData({
                                        cpjzz: false
                                    });
                                }
                            }
                        });
                    }
                });
            } else {
                console.log('alldie');
                that.setData({
                    cpjzz: false
                });
            }
        },

        scrollFun: function (t) {
            if (60 < t.detail.scrollTop && !this.iszd && '2' == this.storeset.top_style) {
                uni.pageScrollTo({
                    scrollTop: this.navzdoffsetTop
                });
                this.setData({
                    iszd: true
                });
            }
            this.dishes;
            for (var a = this.dataheith, e = (this.catalogSelect, t.detail.scrollTop), o = 0; o < a.length; o++) {
                if (e <= a[o]) {
                    this.setData({
                        catalogSelect: o,
                        toType: 'type' + (o - 2)
                    });
                    break;
                }
            }
        },

        selectMenu: function (t) {
            this.dishes;
            var that = this;
            var e = (uni.getStorageSync('users').id, that.store_id, t.currentTarget.dataset.itemIndex);
            this.setData({
                catalogSelect: t.currentTarget.dataset.itemIndex,
                toView: 'order' + e.toString(),
                toType: 'type' + (e - 2),
                scroll: ''
            });
            setTimeout(function () {
                that.setData({
                    scroll: 'scroll'
                });
            }, 500);
        },

        swiperChange: function (t) {
            console.log(t);
            this.setData({
                selectedindex: t.detail.current
            });
        },

        showcart: function () {
            this.setData({
                share_modal_active: !this.share_modal_active
            });
        },

        closecart: function () {
            this.setData({
                share_modal_active: false
            });
        },

        clear: function () {
            var that = this;
            var s = this.dishes;
            var a = uni.getStorageSync('users').id;
            var e = that.store_id;
            console.log(s, a, e);
            uni.showModal({
                title: '提示',
                content: '确定清空此商家的购物车吗？',
                success: function (t) {
                    if (t.confirm) {
                        console.log('用户点击确定');
                        uni.showLoading({
                            title: '正在加载',
                            mask: true
                        });
                        app.globalData.util.request({
                            url: 'entry/wxapp/DelCar',
                            cachetime: '0',
                            data: {
                                user_id: a,
                                store_id: e
                            },
                            success: function (t) {
                                console.log(t.data);
                                if ('1' == t.data) {
                                    for (var a = 0; a < s.length; a++) {
                                        for (var e = 0; e < s[a].good.length; e++) {
                                            s[a].good[e].quantity = 0;
                                        }
                                    }
                                    that.setData({
                                        dishes: s,
                                        share_modal_active: false
                                    });
                                    that.gwcreload();
                                }
                            }
                        });
                    } else {
                        if (t.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                }
            });
        },

        subText: function () {
            //console.log(this);
            var t;
            var a = parseFloat(this.cart_list.money);
            var e = parseFloat(this.start_at);
            console.log(a, e);
            if (a <= 0);
            else if (a < e) {
                var o = e - a;
                console.log(o);
                t = '还差' + o.toFixed(2) + '元起送';
            } else {
                console.log(a);
                t = '去结算';
            }
            this.setData({
                subtext: t
            });
        },

        maketel: function (t) {
            var that = this;
            var e = this.store.tel;
            var o = this.paytel;
            console.log(o);
            if ('-1' != o.indexOf('****')) {
                uni.showModal({
                    title: '提示',
                    content: '查看电话需付费' + getApp().globalData.xtxx.pay_money + '元',
                    success: function (t) {
                        if (t.confirm) {
                            console.log('用户点击确定');
                            app.globalData.util.request({
                                url: 'entry/wxapp/telPay',
                                cachetime: '0',
                                data: {
                                    openid: that.userinfo.openid,
                                    pay_money: getApp().globalData.xtxx.pay_money
                                },
                                success: function (t) {
                                    uni.requestPayment({
                                        timeStamp: t.data.timeStamp,
                                        nonceStr: t.data.nonceStr,
                                        package: t.data.package,
                                        signType: t.data.signType,
                                        paySign: t.data.paySign,
                                        success: function (t) {
                                            console.log(t);
                                        },
                                        complete: function (t) {
                                            console.log(t);
                                            if ('requestPayment:fail cancel' == t.errMsg) {
                                                uni.showToast({
                                                    title: '取消支付'
                                                });
                                            }
                                            if ('requestPayment:ok' == t.errMsg) {
                                                uni.showToast({
                                                    title: '支付成功',
                                                    duration: 1000
                                                });
                                                that.setData({
                                                    paytel: e
                                                });
                                            }
                                        }
                                    });
                                }
                            });
                        }
                    }
                });
            } else {
                uni.makePhoneCall({
                    phoneNumber: e
                });
                that.setData({
                    paytel: e
                });
            }
        },

        location: function () {
            var t = this.store.coordinates.split(',');
            var a = this.store;
            console.log(t);
            uni.openLocation({
                latitude: parseFloat(t[0]),
                longitude: parseFloat(t[1]),
                address: a.address,
                name: a.name
            });
        },

        pjmore: function () {
            console.log('上拉加载', this.pagenum);
            this.mygd ||
                !this.jzgd ||
                this.isjzz ||
                (this.setData({
                    jzgd: false
                }),
                this.getstorelist());
        },

        jumps() {
            console.log('占位：函数 jumps 未声明');
        },

        formReset() {
            console.log('占位：函数 formReset 未声明');
        },

        trueFun() {
            console.log('占位：函数 true 未声明');
        },

        qsy() {
            console.log('占位：函数 qsy 未声明');
        }
    }
};
</script>
<style>
@import './indextakeout.css';
</style>
